package park.job;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import park.log.ExtendedRollingFileAppender;

import java.util.Properties;

public class PressTest
{
    private static Logger logger = Logger.getLogger(PressTest.class);

    public static void main(String[] args)
    {
        init4Log();
        JobExecutor executor = new JobExecutor();

        try
        {
            executor.run(1000*60*60*20);
        }
        catch (Exception e)
        {
            // TODO Auto-generated catch block
            logger.warn(e.getMessage(), e);
        }
    }

    private static void init4Log()
    {
        Properties prop = new Properties();
        prop.put("log4j.rootCategory", "DEBUG, FILE, CONSOLE");
        prop.put("log4j.appender.CONSOLE", "org.apache.log4j.ConsoleAppender");
         //只打印info以上的级别，如需要查看详细信息，可以设为 DEBUG
        prop.put("log4j.appender.CONSOLE.Threshold", "info");
        prop.put("log4j.appender.CONSOLE.Target", "System.out");
        prop.put("log4j.appender.CONSOLE.layout", "org.apache.log4j.PatternLayout");
        prop.put(
                "log4j.appender.CONSOLE.layout.ConversionPattern",
                "%d{yyyy-MM-dd HH:mm:ss.SSS}[thr:%t] %c{1}: [%p] %m%n");

        prop.put("log4j.appender.FILE", ExtendedRollingFileAppender.class.getName());
        //只打印info以上的级别，如需要查看详细信息，可以设为 DEBUG
        prop.put("log4j.appender.FILE.Threshold", "info");
        prop.put("log4j.appender.FILE.MaxFileSize", "8MB");
        prop.put("log4j.appender.FILE.MaxBackupIndex", "20");
        prop.put("log4j.appender.FILE.File", "./log/log.log");
        prop.put("log4j.appender.FILE.layout", "org.apache.log4j.PatternLayout");
        prop.put(
                "log4j.appender.FILE.layout.ConversionPattern", "%d{yyyy-MM-dd HH:mm:ss.SSS}[thr:%t] %c{1}: [%p] %m%n");
        prop.put("log4j.appender.FILE.Append", "true");

        PropertyConfigurator.configure(prop);
    }
}
